<?php

/**
 * specials actions.
 *
 * @package    sf_sandbox
 * @subpackage specials
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class specialsActions extends sfActions
{
  public function executeIndex()
  {
    $this->specialsList = SpecialsPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new SpecialsForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new SpecialsForm(SpecialsPeer::retrieveByPk($request->getParameter('specials_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new SpecialsForm(SpecialsPeer::retrieveByPk($request->getParameter('specials_id')));

    $this->form->bind($request->getParameter('specials'));
    if ($this->form->isValid())
    {
      $specials = $this->form->save();

      $this->redirect('specials/edit?specials_id='.$specials->getSpecialsId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($specials = SpecialsPeer::retrieveByPk($request->getParameter('specials_id')));

    $specials->delete();

    $this->redirect('specials/index');
  }
}
